package com.ssy.lingxi.product.repository.customer;

import com.ssy.lingxi.product.entity.customer.CustomerAttributeValue;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

/**
 * 属性值持久化层
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/6/22
 */
public interface CustomerAttributeValueRepository extends JpaRepository<CustomerAttributeValue,Long>, JpaSpecificationExecutor<CustomerAttributeValue> {
    Page<CustomerAttributeValue> findByMemberIdAndMemberRoleIdAndValueContainingAndCustomerAttributeIdOrderByIdDesc(Long memberId, Long memberRoleId, String value,Long customerAttributeId, Pageable page);

    List<CustomerAttributeValue> findByMemberIdAndMemberRoleIdAndCustomerAttributeIdAndValueAndIdNot(Long memberId, Long memberRoleId, Long customerAttributeId, String value, Long id);

    List<CustomerAttributeValue> findByMemberIdAndMemberRoleIdAndCustomerAttributeIdAndValue(Long memberId, Long memberRoleId, Long customerAttributeId, String value);

    List<CustomerAttributeValue> findByMemberIdAndMemberRoleIdAndCustomerAttributeId(Long memberId, Long memberRoleId, Long id);

    List<CustomerAttributeValue> findByMemberIdAndMemberRoleIdAndAttributeValueId(Long memberId, Long memberRoleId, Long id);

    CustomerAttributeValue findFirstByMemberIdAndMemberRoleIdAndValue(Long memberId, Long memberRoleId, String value);

    //平台后台
    List<CustomerAttributeValue> findByAttributeValueId(Long id);

    List<CustomerAttributeValue> findByMemberIdAndMemberRoleId(Long memberId, Long memberRoleId);
}
